import Vue from 'vue'
import VueRouter from 'vue-router'

// import Reg from '@/views/reg/reg.vue'
const Reg = () => import('@/views/reg/reg.vue')
// import Login from '@/views/login/login.vue'
const Login = () => import('@/views/login/login.vue')
// import Main from '@/views/main/main.vue'
const Main = () => import('@/views/main/main.vue')
// import Home from '@/views/menus/Home/Home.vue'
const Home = () => import('@/views/menus/Home/Home.vue')
// import UserInfo from '@/views/menus/User/UserInfo.vue'
const UserInfo = () => import('@/views/menus/User/UserInfo.vue')
// import UserAvatar from '@/views/menus/User/Useravatar.vue'
const UserAvatar = () => import('@/views/menus/User/Useravatar.vue')
// import UsrPwd from '@/views/menus/User/UserPwd.vue'
const UsrPwd = () => import('@/views/menus/User/UserPwd.vue')
// import ArtCate from '@/views/menus/article/ArtCate.vue'
const ArtCate = () => import('@/views/menus/article/ArtCate.vue')
// import ArtList from '@/views/menus/article/ArtList.vue'
const ArtList = () => import('@/views/menus/article/ArtList.vue')

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  { path: '/reg', component: Reg },
  { path: '/login', component: Login },
  {
    path: '/',
    component: Main,
    redirect: '/home',
    children: [
      { path: 'home', component: Home },
      { path: 'user-info', component: UserInfo },
      { path: 'user-avatar', component: UserAvatar },
      { path: 'user-pwd', component: UsrPwd },
      { path: 'art-cate', component: ArtCate },
      { path: 'art-list', component: ArtList }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
